package com.caigou.task;


import com.caigou.bean.vo.EsArticleMqVO;
import com.caigou.enums.Constant;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.bridge.MessageWriter;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/test")
@Slf4j
public class TestArticleMq {

    @Resource
    private AmqpTemplate amqpTemplate;

    @GetMapping("/fun1")
    void fun1() {
        log.info("执行更新mq操作");

        List<EsArticleMqVO> list = new ArrayList<>();
        list.add(new EsArticleMqVO("403516051507118080",Constant.UPDATE_ARTICLE));
        amqpTemplate.convertAndSend(Constant.CMS_ARTICLE_QUEUE, Arrays.asList(new EsArticleMqVO("403516051507118080",Constant.DELETE_ARTICLE)));
    }

    @GetMapping("/fun2")
    void fun2() {
        System.out.println("士大夫");

        amqpTemplate.convertAndSend(Constant.CMS_KEYWORD_QUEUE,4654);
    }

}
